﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RM.Common.PowerHelper
{
    /// <summary>
    /// 所有模块列表
    /// </summary>
    public enum ModuleType
    {
        None,
        CoreMenu,
        CoreJobTitle,
        CoreJobTitleUser,
        CoreDept,
        CoreDeptUser,
        CoreRole,
        CoreUser,
        CoreRoleUser,
        CoreRoleModule,
        CoreLog,
        CoreConf,
        CorePassword,
        CoreOnlineUser,
        AppFile,
        AppTest
    }


    /// <summary>
    /// 模块帮助类
    /// </summary>
    public partial class ModuleTypeHelper
    {
        /// <summary>
        /// 模块的显示标题
        /// </summary>
        /// <param name="moduleName"></param>
        /// <returns></returns>
        public static string GetTitle(string moduleName)
        {
            return GetTitle(String2Module(moduleName));
        }

        /// <summary>
        /// 模块的显示标题
        /// </summary>
        /// <param name="module"></param>
        /// <returns></returns>
        public static string GetTitle(ModuleType module)
        {
            string result = "未定义！";

            switch (module)
            {
                case ModuleType.CoreMenu:
                    result = "菜单模块管理";
                    break;
                case ModuleType.CoreJobTitle:
                    result = "职称管理";
                    break;
                case ModuleType.CoreJobTitleUser:
                    result = "职称用户管理";
                    break;
                case ModuleType.CoreDept:
                    result = "部门管理";
                    break;
                case ModuleType.CoreDeptUser:
                    result = "部门用户管理";
                    break;
                case ModuleType.CoreRole:
                    result = "角色管理";
                    break;
                case ModuleType.CoreUser:
                    result = "用户管理";
                    break;
                case ModuleType.CoreRoleUser:
                    result = "角色用户管理";
                    break;
                case ModuleType.CoreRoleModule:
                    result = "角色模块权限管理";
                    break;
                case ModuleType.CoreLog:
                    result = "日志管理";
                    break;
                case ModuleType.CoreConf:
                    result = "系统配置";
                    break;
                case ModuleType.CorePassword:
                    result = "修改密码";
                    break;
                case ModuleType.CoreOnlineUser:
                    result = "在线统计";
                    break;
                case ModuleType.AppFile:
                    result = "文件管理";
                    break;
                case ModuleType.AppTest:
                    result = "测试模块";
                    break;
            }

            return result;
        }

        /// <summary>
        /// 字符串转换为ModuleType
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        public static ModuleType String2Module(string text)
        {
            return String2Module(text, false);
        }

        /// <summary>
        /// 字符串转换为ModuleType
        /// </summary>
        /// <param name="text"></param>
        /// <param name="ignoreCase"></param>
        /// <returns></returns>
        public static ModuleType String2Module(string text, bool ignoreCase)
        {
            if (Enum.IsDefined(typeof(ModuleType), text))
            {
                return (ModuleType)Enum.Parse(typeof(ModuleType), text, ignoreCase);
            }
            else
            {
                return ModuleType.None;
            }
        }

        /// <summary>
        /// ModuleType转换为字符串
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static String Module2String(ModuleType type)
        {
            return type.ToString();
        }

        /// <summary>
        /// 获取所有的模块名称列表
        /// </summary>
        /// <returns></returns>
        public static string[] GetAppModules()
        {
            return Enum.GetNames(typeof(ModuleType));
        }
    }
}
